#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=5e5+1000;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
LL a[maxn],b[maxn];
int main(void)
{
  cin.tie(0);std::ios::sync_with_stdio(false);
  LL n,m,k;cin>>n>>m>>k;
  for(LL i=1;i<=n;i++) cin>>a[i];
  for(LL i=1;i<=m;i++) cin>>b[i];
  if(n<m){
    for(LL i=1;i<=m;i++){
        swap(a[i],b[i]);
    }
    swap(n,m);
  }
 /* debug(n);
  for(LL i=1;i<=n;i++){
    cout<<a[i]<<" ";
  }
  cout<<"\n";
  for(LL i=1;i<=n;i++){
    cout<<b[i]<<" ";
  }
  cout<<"\n";
  debug(m);*/
  LL j=1;
  LL dif=0;
  for(LL i=1;i<=n;i++){
     /// cout<<"i="<<i<<" "<<"j="<<j<<"\n";
      if(a[i]!=b[j]) dif++;
      j++;
      if(j%(m+1)==0) j=1;

      if(dif==k){
        cout<<i<<"\n";
        return 0;
      }
  }
  //debug(dif);
  LL turns=k/dif;
  LL ans=turns*n;
  LL cnt=k-dif*turns;
  LL st=(ans)%m+1;
  LL u=0;
  if(cnt==0){
    cout<<ans<<"\n";
    return 0;
  }
 /* debug(ans);
  debug(u);
  debug(cnt);
  debug(st);*/
  for(LL i=1;i<=n;i++){
    ///cout<<"i="<<i<<"  "<<"j="<<st<<"\n";
    if(a[i]!=b[st]){
        u++;
    }
    ans++;
    st++;
    if(st%(m+1)==0) st=1;

    if(u==cnt){
        cout<<ans<<"\n";
        return 0;
    }
  }
return 0;
}
